﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using WJSHWebApi.DBModel;
using WJSHWebApi.InterFace;
using System.Linq;
using System;
using Microsoft.AspNetCore.Cors;

namespace WJSHWebApi.Controllers
{
    [Route("api/[controller]/[action]")]

    [ApiController]
    [EnableCors("cors")]
    public class TaskView : ControllerBase
    {
        private IDBInterface iDBInterface;
        public TaskView(IDBInterface dBInterface)
        {
            iDBInterface = dBInterface;
        }
        // GET: api/<Rawfoilmachine>
        [HttpGet]
        public IEnumerable<Task_Entity> GetTask()
        {
            var List =iDBInterface.Where<MaterialName_Entity>().ToList();
            return iDBInterface.WhereTask().ToList().Where(x => x.MaterialName !=0 && List.FirstOrDefault(y=>y.MaterialName == x.MaterialName)!=null && x.Remark!=null).ToList();
        }

        [HttpGet]
        public IEnumerable<MaterialName_Entity> GetMaterialName()
        {
            return iDBInterface.Where<MaterialName_Entity>().ToList();
        }
    }
}
